---@class Battle.AiRepeater:Battle.AiDecorator
---@field New fun():Battle.AiRepeater
local AiRepeater = Battle.CreateClass("AiRepeater",Battle.AiDecorator)
Battle.AiRepeater = AiRepeater
---@param repeatCount -1:无数次,正数：固定次
function AiRepeater:SetParam(repeatCount)
    self.repeatCount = repeatCount
end
function AiRepeater:onInitialize()
    self.curCount = self.repeatCount
end
function AiRepeater:tick(dt)

    return self:doTick(dt)
end
function AiRepeater:update(dt)
    if self.curCount == 0 then
        return Battle.AiTreeStatus.SUCCESS
    end
    if self.status ~= Battle.AiTreeStatus.RUNNING then
        if self.curCount > 0 then
            self.curCount = self.curCount - 1
        end
        if self.curCount > 0 or self.curCount == -1 then
            self.child:reset()
        end
    end

    if not self.child then return end
    local status = self.child:tick(dt)
    return status
end
